home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ARCHIVES.SWG / 0007_Testing for PKLITE File.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  33 lines

  1. {
  2.  > Your approach (as all similar ones I have seen so Far) has a major
  3.  > drawback: you can't use PKLITE, TinYPROG, LZEXE afterwards to
  4.  > squeeze them down in size, as the offsets of the Program change.
  5.  > Has anyone come up With a another approach circumventing this?
  6.  
  7. Yes, you can store it at the end of the .EXE File ( after the
  8. code ) With the following routine :
  9. }
  10.  
  11. Function CodeLenOnDisk( FName : String ) : LongInt;
  12. Var ImageInfo : Record
  13.                   ExeID     : Array[ 0..1 ] of Char;
  14.                   Remainder : Word;
  15.                   Size : Word
  16.                 end;
  17.     F        : File;
  18. begin
  19.   Assign( F, FName );
  20.   Reset( F, 1 );
  21.   if Ioresult <> 0 then Exit;
  22.   BlockRead( F, ImageInfo, Sizeof( ImageInfo ));
  23.   if ImageInfo.ExeID <> 'MZ' then Exit;
  24.   CodeLenOnDisk := LongInt( ImageInfo.size-1 )*512 + ImageInfo.Remainder;
  25. end;
  26.  
  27. {
  28. With this one, you can determine the end of the code in your .EXE File,
  29. and then Write other data there, Drawback : This Dosen't work in network
  30. environments or With shared .EXE Files. I'd recommend an external passWord
  31. File, and there storing a hash of the passWord.
  32. }
  33.